#ifndef __FILEUTIL_H__
#define __FILEUTIL_H__

#pragma pack(4)
typedef struct
{
    int totalsize;
    int currentIndex;
    int size;
    int bContinue;
    char *fileName;
    char *filePath;
    char *bytes;
    char *md5_value;
} FileInfo;

typedef struct
{
    long lastTime;
    FileInfo *fileInfos;
    int isend;
    char *filePath;
    char *fileName;
    long currentIndex;
    long size;
    long totalSize;
    char *clientId;
} FileInfoRecord;

int createDir(char *dirpath);

int createfile(char *filepath);

int appendFile(char *filepath, char *bytes);

int isExist(char *filepath);

FileInfo *readFile(char *filepath, long offset, int size);

int writeFileInfo(FileInfo *fileinfo, char *filepath);

void readFileByFileInfoRecord(FileInfoRecord *fileInfoRecord);

unsigned long getfilesize(char *filepath);

char *getfilename(char *filepath);

long get_file_totalSize(char *filepath);

void freeFileInfo(FileInfo *fileInfo);

void copyByte(char *target, char *src, int srcpos, int tarpos, int length);

FileInfo *create_file_info();

//检查磁盘大小
int check_has_disk(long total_size);
//post文件到制定服务器
void post_img_file(char *file_path, char *file_name);
//根据目标类型创建文件夹
char *create_dist_file(int file_type, char *file_name);

#endif
